<template>
	<div id="poCustomerStatus" class="poCustomerStatus">
		<div id="poCustomerStatusSubtitle" class="poCustomerStatusSubtitle">
			<tab :scroll-threshold="max">
				<tab-item :selected="page === 'notStart'" @on-item-click="notStart">未开始</tab-item>
				<tab-item :selected="page === 'inProgress'" @on-item-click="inProgress">工作中</tab-item>
				<tab-item :selected="page === 'completeDemo'" @on-item-click="completeDemo">已试听</tab-item>
				<tab-item :selected="page === 'stage'" @on-item-click="stage">跟踪阶段</tab-item>
				<tab-item :selected="page === 'win'" @on-item-click="win">已成单</tab-item>
			</tab>
		</div>

		<div v-if="page == 'notStart'">
			<PoCustomerList curURL="ai/sales/pages/getPoCustomerByStage" type="0" jumpToObjectDetails="customerDetails"></PoCustomerList>
		</div>
		<div v-else-if="page == 'inProgress'">
			<PoCustomerList curURL="ai/sales/pages/getPoCustomerByStage" type="1" jumpToObjectDetails="customerDetails"></PoCustomerList>
		</div>
		<div v-else-if="page == 'completeDemo'">
			<PoCustomerList curURL="ai/sales/pages/getPoCustomerByStage" type="2" jumpToObjectDetails="customerDetails"></PoCustomerList>
		</div>
		<div v-else-if="page == 'stage'">
			<PoCustomerList curURL="ai/sales/pages/getPoCustomerByStage" type="3" jumpToObjectDetails="customerDetails"></PoCustomerList>
		</div>
		<div v-else-if="page == 'win'">
			<PoCustomerList curURL="ai/sales/pages/getPoCustomerByStage" type="4" jumpToObjectDetails="customerDetails"></PoCustomerList>
		</div>

	</div>
</template>

<script>
	import bus from '@/event/eventBus'
	import PoCustomerList from '../../../../components/mobile/scroller/scrollerPoCustomerList'
	import NetWorking from '../../../../utils/networking'
	import {Tab, TabItem, Badge} from 'vux'
	export default {
		name: "poCustomerStatus",
		components: {
			PoCustomerList,
			Tab,
			TabItem,
			Badge
		},
		data() {
			return {
				max: 5,
				page: 'notStart'
			}
		},
		beforeRouteLeave(to, from, next){

			//存储当前页面信息
			this.$store.commit('CREATE_URL_PARAMS', {name: from.name, params: this.page})
			next()
		},
		created: function () {
			bus.$emit("userDefinedEvent", 2)
			bus.$emit("barController", 1)
			bus.$emit("setTopSimpleTitle", '潜在客户')

			this.$store.commit('FETCH_URL_PARAMS')
			if(this.$store.state.user.urlParamsMap !=null && this.$store.state.user.urlParamsMap["poCustomerStatus"] != null){
				this.page = this.$store.state.user.urlParamsMap["poCustomerStatus"].params
			}
		},
		/*watch: {
			page: function () {
				NetWorking.doGet(
					'notification/getPendingActivityNum',
					null,
					null
				).then(
					response => {
						let rs = response.data
						if(rs.error_code == 0){
							this.$store.dispatch('createPendingActNum', rs.pending_act_num)
						}else{
							alert(rs.error_message)
						}
					}
				)
			}
		},*/
		methods: {
			notStart() {
				this.page = 'notStart'
			},
			inProgress() {
				this.page = 'inProgress'
			},
			completeDemo() {
				this.page = 'completeDemo'
			},
			stage() {
				this.page = 'stage'
			},
			win() {
				this.page = 'win'
			}
		}
	}
</script>

<style>
	.poCustomerStatusSubtitle {
		margin-top: 46px;
		position: relative;
		z-index: 99;
	}

	.badge-value {
		display: inline-block!important;
	}

	.pendingBadge {
		margin-bottom: 10px;
		margin-left: 2px;
	}
</style>
